﻿using System.Configuration;
using System.Diagnostics;

namespace MvcShop.MVC.Handlers.Resources
{
    /// <summary>
    /// 资源管理配置节点
    /// </summary>
    public class ResourcesSettingsSection:ConfigurationSection
    {
        public const string SectionName = "resourcesSettings";

        internal const bool DefaultGenerateETag = true;
        internal const bool DefaultCompress = true;
        internal const float DefaultCacheDurationInDays = 365f;

        [ConfigurationProperty("compress", DefaultValue = DefaultCompress)]
        public bool Compress
        {
            [DebuggerStepThrough]
            get { return (bool)this["compress"]; }
            [DebuggerStepThrough]
            set { this["compress"] = value; }
        }

        [ConfigurationProperty("generateETag", DefaultValue = DefaultGenerateETag)]
        public bool GenerateETag
        {
            [DebuggerStepThrough]
            get { return (bool)this["generateETag"]; }
            [DebuggerStepThrough]
            set { this["generateETag"] = value; }
        }

        [ConfigurationProperty("cacheDurationInDays", DefaultValue = DefaultCacheDurationInDays)]
        public float CacheDurationInDays
        {
            [DebuggerStepThrough]
            get { return (float)this["cacheDurationInDays"]; }
            [DebuggerStepThrough]
            set { this["cacheDurationInDays"] = value; }
        }

        [ConfigurationProperty("version")]
        public string Version
        {
            [DebuggerStepThrough]
            get { return (string)this["version"]; }
            [DebuggerStepThrough]
            set { this["version"] = value; }
        }

        [ConfigurationProperty("resourcess", IsDefaultCollection = true, IsRequired = true)]
        public ResourcesElementCollection Resourcess
        {
            [DebuggerStepThrough]
            get
            {
                return (ResourcesElementCollection)base["resourcess"] ?? new ResourcesElementCollection();
            }
        }
    }
}
